<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsinfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间:{{newsinfo.add_time|Time}}</span>
      <span>点击:{{newsinfo.click}}次</span>
    </p>
    <hr />
    <div class="content" v-html="newsinfo.content"></div>
    
    <comment :id="id"></comment>
  </div>
</template>
<script>
//按需导入提示组件
import { Toast } from "mint-ui";
// 导入评论组件
import comment from '../subcomponents/comment.vue'
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsinfo:{}
    };
  },
 created() {
    this.getnewsinfo();
  },
  methods: {
    getnewsinfo() {
       this.$https
        .get("http://www.liulongbin.top:3005/api/getnew/"+this.id)
        .then(res => {
          //console.log(res.data);
          if (res.data.status === 0) {
            //成功了
            this.newsinfo = res.data.message[0];
          } else {
            Toast("加载新闻资讯详情数据失败");
          }
        })
        .catch(err => {
          console.log(err);
        });
    }
  },
  components:{
       comment
  }
};
</script>
<style lang="scss" scoped>
.newsinfo-container {
  padding: 0 4px;
  .title {
    font-size: 16px;
    text-align: center;
    color: red;
    margin: 15px 0;
  }
  .subtitle {
    font-size: 13px;
    color: blue;
    display: flex;
    justify-content: space-between;
  }
  
}
</style>